<template>
  <div class="pickTask">
    <div class="publicSearch">
      <div class="searchBar" :style="{ height: isMoreSearch ? 'auto' : '' }">
        <el-button-group>
          <el-button @click="getPickTaskData" size="mini" icon="el-icon-search"
            >查询</el-button
          >
          <el-button @click="clearSearchData" size="mini" icon="el-icon-refresh"
            >重置</el-button
          >
        </el-button-group>
        <!--<div>
          <span>关键字搜索</span>
          <el-input v-model="searchData.keyWords" size="mini" placeholder="仓库名称/货主名称" clearable></el-input>
        </div>-->
        <div>
          <span>出库任务号</span>
          <el-input
            v-model="searchData.billNo"
            size="mini"
            placeholder="请输入出库任务号"
            clearable
          ></el-input>
        </div>
        <div>
          <span>拣货任务号</span>
          <el-input
            v-model="searchData.pickTaskCode"
            size="mini"
            placeholder="拣货任务号"
            clearable
          ></el-input>
        </div>
        <!-- <div>
          <span>货主</span>
          <el-select
            v-model="searchData.organizationId"
            size="mini"
            filterable
            placeholder="请选择货主"
            clearable
          >
            <el-option
              v-for="item in organizations"
              :key="item.organizationId"
              :label="item.organizationName"
              :value="item.organizationId"
            >
            </el-option>
          </el-select>
        </div> -->
        <div>
          <span>物料编码</span>
          <el-input
            v-model="searchData.itemCode"
            size="mini"
            placeholder="请输入物料编码"
            clearable
          ></el-input>
        </div>
        <div>
          <span>物料名称</span>
          <el-input
            v-model="searchData.itemName"
            size="mini"
            placeholder="请输入物料名称"
            clearable
          ></el-input>
        </div>
        <div>
          <span>追踪号</span>
          <el-input
            v-model="searchData.boxCode"
            size="mini"
            placeholder="请输入追踪号"
            clearable
          ></el-input>
        </div>
        <div>
          <span>批次号</span>
          <el-input
            v-model="searchData.batchName"
            size="mini"
            placeholder="请输入批次号"
            clearable
          ></el-input>
        </div>
        <!-- <div>
          <span>拣货状态</span>
          <el-select
            v-model="searchData.state"
            size="mini"
            filterable
            placeholder="请选择来源"
            clearable
          >
            <el-option
              v-for="item in pickTaskType"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              @click="stateCheck(item.value)"
            >
            </el-option>
          </el-select>
        </div> -->
        <!-- <div>
          <span>库区编码/名称</span>
          <el-input
            v-model="searchData.areaCode"
            size="mini"
            placeholder="请输入库区编码/名称"
            clearable
          ></el-input>
        </div> -->
        <!-- <div>
          <span>货架编码/名称</span>
          <el-input
            v-model="searchData.shelfCode"
            size="mini"
            placeholder="请输入货区编码/名称"
            clearable
          ></el-input>
        </div> -->
        <div>
          <span>货位编码/名称</span>
          <el-input
            v-model="searchData.cellCode"
            size="mini"
            placeholder="请输入货位编码/名称"
            clearable
          ></el-input>
        </div>
        <!-- <div>
          <span>关键字搜索</span>
          <el-input
            v-model="searchData.keyWords"
            size="mini"
            placeholder="箱号/LPN"
            clearable
          ></el-input>
        </div> -->
      </div>
      <span
        class="moreSearchBtn"
        :class="isMoreSearch ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
        @click="isMoreSearch = !isMoreSearch"
      ></span>
    </div>

    <div class="headerBtns">
      <el-button size="small" type="success" round  @click="commitCancel()" :disabled="multipleSelection.length <= 0"> 任务取消
      </el-button>
      <!-- <div class="rightFloat" v-if="sysJob.status !== null || sysJob.status !== undefined || sysJob.status !== ''">
        <span>自动生成拣货任务&nbsp;:&nbsp;</span>
        <el-switch
                v-model="sysJob.status"
                active-color="#13ce66"
                inactive-color="#ff4949"
                active-text="是"
                inactive-text="否"
                active-value="0"
                inactive-value="1"
                @change="editSysJob"
        >
        </el-switch>
      </div> -->
    </div>

    <el-dialog
      title="拣货确认"
      :visible.sync="dialogNewVisible"
      :before-close="handleClose"
      :close-on-click-modal="false"
      width="1000px"
      style="margin-top: -10vh"
    >
      <div class="upperTacticBox">
        <el-form class="searchBar" :model="form" :rules="rules" ref="form">
          <el-form-item label="仓库" :label-width="formLabelWidth">
            <el-input v-model="form.wareName" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="发运单号" :label-width="formLabelWidth">
            <el-input v-model="form.billNo" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="货主" :label-width="formLabelWidth">
            <el-input
              v-model="form.organizationName"
              disabled="true"
            ></el-input>
          </el-form-item>
          <el-form-item label="货区编码" :label-width="formLabelWidth">
            <el-input v-model="form.areaCode" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="货架编码" :label-width="formLabelWidth">
            <el-input v-model="form.shelfCode" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="货位编码" :label-width="formLabelWidth">
            <el-input v-model="form.cellCode" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="物料编码" :label-width="formLabelWidth">
            <el-input v-model="form.itemCode" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="物料名称" :label-width="formLabelWidth">
            <el-input v-model="form.itemName" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="批次" :label-width="formLabelWidth">
            <el-input v-model="form.batchName" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="追踪号" :label-width="formLabelWidth">
            <el-input v-model="form.boxCode" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="单位" :label-width="formLabelWidth">
            <el-input v-model="form.packDescribe" disabled="true"></el-input>
          </el-form-item>
          <el-form-item label="拣货数量" :label-width="formLabelWidth">
            <el-input v-model="form.pickQuantity"></el-input>
          </el-form-item>
          <!-- <el-form-item
            label="目标货位"
            prop="toCellCode"
            :label-width="formLabelWidth"
          >
            <el-select
              v-model="form.toCellCode"
              filterable
              placeholder="请选择目标货位"
              size="small"
              style="width: 70%"
            >
              <el-option
                v-for="item in cells"
                :key="item.cellCode"
                :label="item.cellCode"
                :value="item.cellCode"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
          <!-- <el-form-item label="目标追踪号" prop="trackingNum" :label-width="formLabelWidth">
            <el-input v-model="form.trackingNum" placeholder="请输入目标追踪号" ></el-input>
          </el-form-item> -->
          <!-- <el-form-item label="备注"  :label-width="formLabelWidth">
            <el-input v-model="form.memo" placeholder="请输入备注" ></el-input>
          </el-form-item> -->
        </el-form>
        <div style="float: left; width: 100%"></div>
        
      </div>

      <div slot="footer" class="dialog-footer">
        <!-- <el-button
          style="margin-right: 550px"
          type="primary"
          @click="showSerialNo()"
          :disabled="serialNo1.length <= 0"
          >序列号({{ serialNo1.length }})</el-button
        > -->
        <el-button
          @click="
            resetForm('form');
            dialogNewVisible = false;
          "
          >取 消</el-button
        >
        <el-button type="primary" @click="pickTask('form')">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 序列号 -->
    <el-dialog
      title="序列号"
      :visible.sync="serialNo"
      :before-close="handleCloseSerialNo"
      width="900px"
      style="margin-top: -10vh"
    >
      <div class="cellModalBox">
        <el-form class="clearFloat" :model="form" :rules="rules" ref="form">
          <el-form-item label="扫描输入框" :label-width="formLabelWidth">
            <el-input
              v-model="scanner"
              id="scanner"
              @change="addSerialNo()"
              placeholder="请扫描序列号"
              style="width: 90%"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              @click="affirmSerialNo()"
              :disabled="select"
              >确 定</el-button
            >
          </el-form-item>
          <el-form-item label="是否自动提交">
            <el-switch
              v-model="select"
              active-color="#13ce66"
              inactive-color="#ff4949"
              active-text="是"
              inactive-text="否"
              :active-value="true"
              :inactive-value="false"
            >
            </el-switch>
          </el-form-item>
          <!-- 根据数量生成输入框 -->
          <div style="float: left; width: 100%">
            <el-divider content-position="left">序列号</el-divider>
          </div>

          <!--<el-form-item v-for="(item,index) in serialNo1" :label="'序列号'+index"  :label-width="formLabelWidth">
            <el-input v-model="item.serialNo" v-bind:id="'serialNoId'+item.serialNoId" placeholder="请扫描" style="width: 80%;" disabled></el-input>
          </el-form-item>-->
          <el-tag
            v-for="(item, i) in serialNo1"
            :key="i"
            :style="i === 0 ? '' : 'margin-left: 10px;;margin-top:10px;'"
            v-bind:id="'serialNoId' + item.serialNoId"
          >
            {{ item.serialNo }}
          </el-tag>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCloseSerialNo()">取 消</el-button>
        <el-button type="primary" @click="serialNo = false">确 定</el-button>
      </div>
    </el-dialog>

    <!-- :span-method="objectSpanMethod"  -->
    <div class="tableBox">
      <el-table
        v-loading="loading.masterTable"
        highlight-current-row
        @selection-change="handleSelectionChange"
        :data="pickTasks"
        style="width: 100%"
      >
        <el-table-column type="selection" width="50"> </el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          fixed="left"  
          prop="pickTaskCode"
          label="拣货任务号"
          min-width="150">
        </el-table-column>
        <el-table-column
          sortable
          fixed="left"  
          show-overflow-tooltip
          prop="soMasterCode"
          label="出库任务"
          min-width="150"
        >
         <template slot-scope="scope">
            <span v-if="scope.row.soMasterCode!=null">{{ scope.row.soMasterCode }}</span>
          </template>
        </el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          fixed="left"  
          prop="soMemo"
          label="备注"
          min-width="200">
        </el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="state"
          label="状态"
          min-width="80"
        >
          <template slot-scope="scope">
            <el-tag
              v-for="(item, index) in pickTaskType"
              :key="index"
              v-if="scope.row.state === item.value"
              >{{ item.label }}</el-tag
            >
          </template>
        </el-table-column>

        <el-table-column
          
          show-overflow-tooltip
          prop="billNo"
          label="单据信息"
          min-width="160"
        >
          <template slot-scope="scope">
            <span>货主: </span>
            <span
              class="textBtn"
              @click="
                $EventBus.$emit(
                  'showPublicModal',
                  scope.row.organizationId,
                  'organization'
                )
              "
              >{{ scope.row.organizationName }}</span
            >
            <!-- <br>
            <span>发运单号: </span>
            <span class="textBtn" @click="$router.push({name: 'soBillDetail',params: scope.row})">{{scope.row.billNo}}</span> -->
            <!-- <br>
            <span>客户: </span>
            <span class="textBtn" @click="$parent.showPublicModal(scope.row.customerId, 'customer')">{{scope.row.customerName}}</span> -->
            <br />
            <span>仓库: </span>
            <span
              class="textBtn"
              @click="
                $EventBus.$emit('showPublicModal', scope.row.wareId, 'ware')
              "
              >{{ scope.row.wareName }}</span
            >
          </template>
        </el-table-column>
        
        <el-table-column
          show-overflow-tooltip
          prop="itemCode"
          label="物料"
          min-width="150"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.itemCode }}</span>
            <br />
            <span>{{ scope.row.itemName }}</span>
          </template>
        </el-table-column>

        <el-table-column
          sortable
          show-overflow-tooltip
          prop="batchName"
          label="批次号"
          min-width="160">
        </el-table-column>

        <!-- <el-table-column
          show-overflow-tooltip
          prop="parentTaskId"
          label="parentTaskId"
          min-width="40"
        >
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="pickQuantity"
          label="推荐数量"
          min-width="100"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.pickQuantity / scope.row.transRatio }}</span>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="reviewQuantity"
          label="已拣数量"
          min-width="100"
        >
        </el-table-column>
        <!-- <el-table-column
          show-overflow-tooltip
          prop="allotUserName"
          label="分配人"
          min-width="100"
        >
        </el-table-column> -->
        <!-- <el-table-column
          show-overflow-tooltip
          prop="pickUserName"
          label="执行人"
          min-width="100"
        >
        </el-table-column> -->
        <el-table-column
          show-overflow-tooltip
          prop="boxCode"
          label="跟踪号"
          width="180">
        </el-table-column>
        <!-- <el-table-column
          
          show-overflow-tooltip
          prop="lpn"
          label="跟踪号"
          min-width="80">
        </el-table-column> -->
        <el-table-column
          
            show-overflow-tooltip
            prop="areaCode"
            label="推荐库区"
            width="120">
            <template slot-scope="scope">
              <span>{{ scope.row.areaCode }}</span>
             
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="cellCode"
          label="推荐货位"
          width="120"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.cellCode }}</span>
          </template>
        </el-table-column>
        
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="createTime"
          label="任务创建时间"
          width="160">
          <template slot-scope="scope">
              <span>{{ scope.row.createTime }}</span>
          </template>
        </el-table-column>

        

        <el-table-column
          show-overflow-tooltip
          prop="soDetailId"
          label="来源明细ID"
          width="150"
        >
         <template slot-scope="scope">
            <span v-if="scope.row.soDetailId!=null">{{ scope.row.soDetailId }}</span>
          </template>
        </el-table-column>
        
        
        <!-- <el-table-column
           
          show-overflow-tooltip
          prop="shelfCode"
          label="货架"
          width="80">
          <template slot-scope="scope">
              <span>{{ scope.row.shelfCode }}</span>
               
          </template>
        </el-table-column>-->

        <el-table-column fixed="right" label="操作" min-width="120">
          <template slot-scope="scope">
            <el-button
              @click="pickTaskAffirm(scope.row)"
              type="primary"
              size="small"
              :disabled="scope.row.state === 2"
              >&nbsp;拣货确认</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        class="pagination-bottom"
        style="text-align: right"
        @current-change="handleCurrentChange"
        :current-page.sync="searchData.pageNum"
        :page-size="searchData.pageSize"
        @size-change="handleSizeChange"
        :page-sizes="[15, 30, 50, 100]"
        layout="sizes,total, prev, pager, next, jumper"
        :total="searchData.total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "pickTask",
  data() {
    return {
      isMoreSearch: false,
      wareId: PF.getLocal("wareId", "number"),
      searchData: {
        pageNum: 1,
        pageSize: 10,
        total: null,
        keyWords: "",
        insertType: -2,
        wareId: PF.getLocal("wareId", "number"),
        billNo: "",
        organizationId: "",
        itemCode: "",
        itemName: "",
        states: "0,1",// 默认已拣货
        batchName: "",
        areaCode: "",
        shelfCode: "",
        cellCode: "",
        pickTaskCode: "",
        boxCode: "",
      },

      loading: {
        masterTable: true,
      },

      rows: [],
      spans: [],
      pickTasks: [],

      cancelButton: false,
      dialogNewVisible: false,
      formLabelWidth: "100px",

      poUdfHs: [],
      buyBillInTypes: [],
      organizations: [],
      suppliers: [],
      multipleSelection: [],
      cells: "",
      form: {
        pickTaskId: "",
        wareName: "",
        billNo: "",
        organizationName: "",
        areaCode: "",
        shelfCode: "",
        cellCode: "",
        itemCode: "",
        itemName: "",
        batchName: "",
        boxCode: "",
        packDescribe: "",
        pickQuantity: "",
        toCellCode: "",
        trackingNum: "",
        memo: "",
        serialNos: [],
      },
      rules: {
        toCellCode: [
          { required: false, message: "请输入目标货位", trigger: "blur" },
        ],
        // trackingNum: [{required: true, message: '请输入追踪号', trigger: 'blur'}],
      },

      sysJob: {},

      serialNo: false,
      serialNo1: [],
      scanner: "",
      select: true,
      cellUserTypes: { 0: -1, 1: 3 },
    };
  },
  computed: {
    ...mapState(["reviewStates", "pickTaskType", "createSource"]),
  },
  methods: {
    handleClose(done) {
      this.dialogNewVisible = false;
    },
    // 状态选择
    stateCheck(value) {
      this.searchData.state = value;
    },
    addSerialNo() {
      if (this.select) {
        this.changeSerialNos();
        let pFocus = document.getElementById("scanner");
        pFocus.focus();
      }
    },
    affirmSerialNo() {
      this.changeSerialNos();
      let pFocus = document.getElementById("scanner");
      pFocus.focus();
    },
    changeSerialNos() {
      for (let i = 0; i < this.serialNo1.length; i++) {
        if (this.scanner === this.serialNo1[i].serialNo) {
          if (this.form.serialNos.length > 0) {
            for (let j = 0; j < this.form.serialNos.length; j++) {
              if (this.scanner === this.form.serialNos[j]) {
                IOT.tips("当前序列号已录入!", "error", 1000, () => {
                  this.scanner = "";
                  let pFocus = document.getElementById("scanner");
                  pFocus.focus();
                });
                return false;
              }
            }
          }
          this.form.serialNos.push(this.serialNo1[i].serialNo);
          this.scanner = "";
          let pFocus = document.getElementById("scanner");
          pFocus.focus();
          document.getElementById(
            "serialNoId" + this.serialNo1[i].serialNoId + ""
          ).style.color = "red";
          break;
        } else if (i === this.serialNo1.length - 1) {
          IOT.tips("当前货物无此序列号!", "error", 1000, () => {
            this.scanner = "";
            let pFocus = document.getElementById("scanner");
            pFocus.focus();
          });
          return false;
        }
      }
    },
    handleCloseSerialNo() {
      this.serialNo = false;
      this.scanner = "";
    },
    showSerialNo() {
      this.serialNo = true;
      let pFocus = document.getElementById("scanner");
      pFocus.focus();
    },
    resetForm(formName) {
      // 重置
      this.$refs[formName].resetFields();
    },
    pickTask(formName) {
      let that = this;
      IOT.showOverlay("保存中，请稍等...");
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let a = Math.ceil(that.form.pickQuantity);
          // if (that.form.serialNos.length <= 0 && this.serialNo1.length > 0) {
          //   this.$confirm(
          //     "当前拣货未录入序列号,会影响后续序列号追踪,是否继续？"
          //   )
          //     .then((_) => {
          //       this.pickTaskAddirms(formName);
          //     })
          //     .catch((_) => {
          //       IOT.hideOverlay();
          //     });
          // } else if (
          //   that.form.serialNos.length > 0 &&
          //   that.serialNo1.length > 0 &&
          //   that.form.serialNos.length < a
          // ) {
          //   this.$confirm(
          //     "当前拣货录入序列号与数量不一致,会影响后续序列号追踪,是否继续？"
          //   )
          //     .then((_) => {
          //       this.pickTaskAddirms(formName);
          //     })
          //     .catch((_) => {
          //       IOT.hideOverlay();
          //     });
          // } else {
            this.pickTaskAddirms(formName);
          // }
        } else {
          IOT.hideOverlay();
          console.error("error submit!!");
          return false;
        }
      });
    },
    pickTaskAddirms(formName) {
      let param = {
        pickTaskId: this.form.pickTaskId,
        toCellCode: this.form.toCellCode,
        // trackingNum: this.form.trackingNum,
        // memo: this.form.memo,
        serialNos: this.form.serialNos,
        wareId: this.wareId,
        pickQuantity: this.form.pickQuantity
      };
      IOT.getServerData("/pick/tasks/commitPick", "post", param, (ret) => {
        IOT.hideOverlay();
        if (ret.code === 200) {
          IOT.tips("保存成功！", "success", 1000, () => {
            this.getPickTaskData();
          });
        } else {
          IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
        }
      });
      this.resetForm(formName);
      this.dialogNewVisible = false;
    },
    pickTaskAffirm(row) {
      this.dialogNewVisible = true;
      let rowData = JSON.parse(JSON.stringify(row));
      this.form.pickTaskId = rowData.pickTaskId;
      this.form.wareName = rowData.wareName;
      this.form.billNo = rowData.billNo;
      this.form.organizationName = rowData.organizationName;
      this.form.areaCode = rowData.areaCode;
      this.form.shelfCode = rowData.shelfCode;
      this.form.cellCode = rowData.cellCode;
      this.form.itemCode = rowData.itemCode;
      this.form.itemName = rowData.itemName;
      this.form.batchName = rowData.batchName;
      this.form.boxCode = rowData.boxCode;
      this.form.packDescribe = rowData.packDescribe;
      this.form.pickQuantity = rowData.pickQuantity - rowData.reviewQuantity;
      // IOT.getServerData(
      //   "/serial/nos/list",
      //   "get",
      //   { type: 2, inventoryId: row.inventoryId },
      //   (ret) => {
      //     IOT.hideOverlay();
      //     if (ret.code === 200) {
      //       this.serialNo1 = ret.rows;
      //     } else {
      //       IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
      //     }
      //   }
      // );
    },
    handleCurrentChange(val) {
      this.searchData.pageNum = val;
      this.getPickTaskData();
    },
    handleSizeChange(val) {
      this.searchData.pageSize = val;
      this.getPickTaskData();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    clearSearchData() {
      this.searchData.keyWords = "";
      this.searchData.billNo = "";
      this.searchData.organizationId = "";
      this.searchData.itemCode = "";
      this.searchData.itemName = "";
      this.searchData.state = "";
      this.searchData.source = "";
      this.searchData.areaCode = "";
      this.searchData.shelfCode = "";
      this.searchData.cellCode = "";
      this.searchData.batchName = "";
      this.searchData.pickTaskCode = "";
      this.searchData.boxCode = "";
    },
    getPickTaskData() {
      let that = this;
      that.loading.masterTable = true;
      // this.searchData.state = 0;
      IOT.getServerData("/pick/tasks/list", "get", this.searchData, (ret) => {
        if (ret.code === 200) {
          let list = ret.rows;
          let billNos = [];
          let spans = [];
          let rows = [];
          for (let i = 0; i < list.length; i++) {
            let index = billNos.indexOf(list[i].billNo);
            if (index === -1) {
              billNos.push(list[i].billNo);
              rows.push(i);
              spans.push({ rowspan: 1, colspan: 1 });
            } else if (index >= 0) {
              spans[index].rowspan++;
            }
          }
          this.rows = rows;
          this.spans = spans;
          this.pickTasks = list;
          this.searchData.total = ret.total;
          this.searchData.pageNum = ret.pageNumber;
          that.loading.masterTable = false;
        } else {
          IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
        }
      });
    },
    commitCancel() {
      let that = this;
      IOT.showOverlay("保存中，请稍等...");
      let form = [];
      form = PF.JSON(this.multipleSelection);
      let ids = [];
      for (let i = 0; i < form.length; i++) {
        if (form[i].state === 3) {
          IOT.tips("请选择未取消的拣货任务！", "error", 1000, () => {
            s;
            IOT.hideOverlay();
          });
          return false;
        }
        ids.push(form[i].pickTaskId);
      }
      IOT.getServerData(
        "/pick/tasks/cancelPickTask",
        "post",
        { ids: ids },
        (ret) => {
          IOT.hideOverlay();
          if (ret.code === 200) {
            IOT.tips("取消成功！", "success", 1000, () => {
              that.getPickTaskData();
            });
          } else {
            IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
          }
        }
      );
    },
    getCellData() {
      IOT.getServerData(
        "/cell/infos/findByCellUserTypes",
        "get",
        { cellUseTypes: this.cellUserTypes, wareId: this.searchData.wareId },
        (ret) => {
          if (ret.code === 200) {
            this.cells = ret.rows;
          } else {
            IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
          }
        }
      );
    },
    getStatus() {
      IOT.getServerData(
        "/monitor/job/list",
        "get",
        {
          methodName: "autoCreatePickTask",
          methodParams: this.searchData.wareId + "",
        },
        (ret) => {
          if (ret.code === 200) {
            this.sysJob = ret.rows[0];
          } else {
            IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
          }
        }
      );
    },
    editSysJob() {
      IOT.getServerData(
        "/monitor/job/changeStatus",
        "post",
        this.sysJob,
        (ret) => {
          if (ret.code === 200) {
            // IOT.tips('修改成功！', 'success', 1000, () => {
            // });
          } else {
            IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
          }
        }
      );
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      let index = this.rows.indexOf(rowIndex);
      if (column.property === "billNo") {
        if (index >= 0) {
          return this.spans[index];
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
    },
  },
  created() {
    this.getPickTaskData();
    this.getCellData();
    //this.getStatus();
    PF.getOrganizations((rows) => {
      this.organizations = rows;
    });
    /*PF.getSysParamUdfData('poUdfHs', [], (data, udfs) => {
        this.poUdfHs = udfs;
      });
      PF.getDataDictUdfData('buyBillInType', (rows) => {
        this.buyBillInTypes = rows;
      });

      PF.getSuppliers((rows) => {
        this.suppliers = rows;
      });*/
  },
  mounted() {},
};
</script>

<style scoped lang="less">
.buyBillInDraft {
}
</style>
